<%--
  Created by IntelliJ IDEA.
  User: aming
  Date: 2022-08-04
  Time: 9:16
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>

    <script src="js/jquery-1.11.0.min.js"></script>

</head>
<body>
    hello springmvc~~ <br>

    <button id="reg">注册</button>

    <hr>

    <button id="btn">访问cross</button>
</body>

<script>
    $("#reg").click(function (){
        //发送异步请求，访问/user/regist.是通过请求体将json格式数据发送到后台，数据格式不再是key=value&key2=value2这种形式
        $.ajax({
            url:"/user/regist",  //请求路径
            data:'{"name":"zhangsan","pwd":"123","birthday":"2022-12-12"}', //携带的参数，json字符串格式
            type:"post",  //请求方式
            contentType:"application/json",  //告诉后台，我发送给你的数据格式是json格式
            success:function (res){  //成功回调
                alert(res)
            }
        });
    });

    $("#btn").click(function (){
        //发送异步请求
        // $.get("http://localhost/user/cross",{},function (data){
        //     alert(data)
        // });

        $.ajax({
            url:"http://localhost/user/cross2",
            type:"get",
            success:function (data){
                alert(data)
            },
            //发送异步请求时，携带cookie认证信息
            xhrFields: {
                withCredentials: true
            }
        });
    });
</script>
</html>
